//
//  OEShareViewController.m
//  OneEightyNine
//
//  Created by Mac on 2019/3/5.
//  Copyright © 2019 stoneobs. All rights reserved.
//

#import "OEShareViewController.h"

@interface OEShareViewController ()
@property(nonatomic, strong) UITextField                     *shopTextFiled;/**<  */
@property(nonatomic, strong) UITextField                     *telePhoneextFiled;/**<  */
@property(nonatomic, strong) STTextView                     *textView;/**<  */
@end

@implementation OEShareViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = OESTRING(@"MY ITEMS TO SHARE");
    [self st_setRightItemWithImage:[UIImage imageNamed:@"32×28分享"]];
    [self configSubView];
//    self.tableView.contentInset = UIEdgeInsetsZero;
//    self.automaticallyAdjustsScrollViewInsets = NO;
//    self.tableView.frame = CGRectMake(0, TMUtils.navgationBarBootom, UIScreenWidth, TMUtils.tabBarTop - TMUtils.navgationBarBootom);
    [self st_autoAdjustAllResponder];
    // Do any additional setup after loading the view.
}
#pragma mark --subView
- (void)configSubView{
    [self configTableHeader];
}
- (void)configTableHeader{
    UIView * header = [[UIView alloc] initWithFrame:CGRectMake(0, 0, UIScreenWidth, 100)];
    header.backgroundColor = OE_LIMITE_COLOR;
    
    //374 × 650
    UIImageView * imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, UIScreenWidth, UIScreenWidth * 650.0 / 374.0)];
    imageView.image = [UIImage imageNamed:@"碎片"];
    [header addSubview:imageView];

    
    UIImageView * simageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, UIScreenWidth, 223)];
    simageView.image = [UIImage imageNamed:@"img"];
    [header addSubview:simageView];
    
    
    UIImageView * cimageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, simageView.bottom, 168, 51)];
    cimageView.image = [UIImage imageNamed:@"335×100文字背景"];
    [header addSubview:cimageView];
    cimageView.centerX = UIScreenWidth / 2;
    ({
        STLabel * label = [self lableWithText:OESTRING(@"WhenSPReaches 100 ") height:25];
        label.textColor = FlatMint;
        label.width = cimageView.width;
        [cimageView addSubview:label];
        
        STLabel * slabel = [self lableWithText:OESTRING(@"We Will have rewards") height:25];
        slabel.textColor = FlatOrange;
        slabel.bottom = cimageView.height - 4;
        slabel.width = cimageView.width;
        [cimageView addSubview:slabel];
    });
    
    STLabel * alertLable = [self lableWithText:OESTRING(@"You can share it TO") height:40];
    alertLable.top = cimageView.bottom + 30;
    alertLable.width = UIScreenWidth;
    [header addSubview:alertLable];
    
    NSArray * array = @[@{@"imageName":@"70×70facebook1",@"title":@"Facebook"},
                        @{@"imageName":@"70×70Instagram1",@"title":@"Insgame"},
                        @{@"imageName":@"70×70Twiter1",@"title":@"Twiter"}];
    CGFloat menuWith = UIScreenWidth / 3;
    for (NSInteger i = 0; i < array.count; i ++) {
        NSDictionary * dic = array[i];
        NSString * imageName = dic[@"imageName"];
        NSString *  title = dic[@"title"];
        STMenuControl * menu = [[STMenuControl alloc] initWithFrame:CGRectMake(0, alertLable.bottom + 20, menuWith, 70) imageName:imageName title:title titleColor:UIColor.whiteColor];
        menu.left = i * menuWith;
        [header addSubview:menu];
//        header.height = menu.bottom + 20;
    }
//    header.height = bimageView.bottom;
    
    
    //底部
    UIImageView * bimageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, alertLable.bottom + 130, UIScreenWidth, 677)];
    bimageView.image = [UIImage imageNamed:@"下半部背景"];
    [header insertSubview:bimageView atIndex:0];
    bimageView.userInteractionEnabled = YES;
    ({
        STLabel * btitleLable = [[STLabel alloc] initWithFrame:CGRectMake(0, 30, UIScreenWidth, 80)
                                                         text:OESTRING(@"You can leave what you like \n Store information")
                                                    textColor:UIColor.whiteColor
                                                         font:16
                                                  isSizetoFit:NO
                                                textAlignment:NSTextAlignmentCenter];
        [bimageView addSubview:btitleLable];
        
        self.shopTextFiled = [self textFiledWithPlaceHolder:OESTRING(@"Shop Name")];
        self.shopTextFiled.top = btitleLable.bottom;
        [bimageView addSubview:self.shopTextFiled];
        
        self.telePhoneextFiled = [self textFiledWithPlaceHolder:OESTRING(@"Shop Name")];
        self.telePhoneextFiled.top = self.shopTextFiled.bottom + 10;
        [bimageView addSubview:self.telePhoneextFiled];
        
        self.textView = [[STTextView alloc] initWithFrame:CGRectMake(20, self.telePhoneextFiled.bottom + 10, UIScreenWidth - 40, 80)];
        self.textView.textColor = UIColor.whiteColor;
        self.textView.layer.cornerRadius = 4;
        self.textView.backgroundColor = [UIColor.whiteColor colorWithAlphaComponent:0.4];
        self.textView.clipsToBounds = YES;
        self.textView.placeholder = OESTRING(@"Shop address");
        self.textView.label.textColor = UIColor.whiteColor;
        self.textView.label.left = 10;
        [bimageView addSubview:self.textView];
        
        UIView * contentView = [[UIView alloc] initWithFrame:CGRectMake(20, self.textView.bottom + 10, UIScreenWidth - 40, 100)];
        contentView.backgroundColor = UIColor.whiteColor;
        contentView.layer.cornerRadius = 4;
        contentView.backgroundColor = [UIColor.whiteColor colorWithAlphaComponent:0.4];
        contentView.clipsToBounds = YES;
        [bimageView addSubview:contentView];
        //内容
        STLabel * subtitleLable = [[STLabel alloc] initWithFrame:CGRectMake(0, 20, 100, 30)
                                                         text:OESTRING(@" ----------- Details -----------")
                                                    textColor:UIColor.whiteColor
                                                         font:16
                                                  isSizetoFit:NO
                                                textAlignment:NSTextAlignmentCenter];
        [NSString lableAutoAdjustWitdhWithLabel:subtitleLable];
        subtitleLable.centerX = contentView.width / 2;
        [contentView addSubview:subtitleLable];
        
        NSString * text = OESTRING(@"1. You can divide daily loaned records by total number of registered users.\n2. Today, a total of 10 cups were lent out,a total of 9 registered users, 10/9 = 1.1,this column can show SP 1.1\n3. If second days are the same, they willbecome SP 2.2\n4. When SP reaches 100, we will have rewards.");
        STLabel * notetitleLable = [[STLabel alloc] initWithFrame:CGRectMake(20, subtitleLable.bottom, contentView.width - 40, 20)
                                                         text:text
                                                    textColor:UIColor.whiteColor
                                                         font:14
                                                  isSizetoFit:NO
                                                textAlignment:NSTextAlignmentLeft];
        [contentView addSubview:notetitleLable];
        [NSString lableAutoAdjustheightWithLabel:notetitleLable];
        contentView.height = notetitleLable.bottom + 30;
        bimageView.height = contentView.bottom + 20;
    });
    header.height = bimageView.bottom;
    self.tableView.tableHeaderView = header;
    
    
}
- (UITextField*)textFiledWithPlaceHolder:(NSString*)placeHolder{
    UITextField * textFiled = [[UITextField alloc] initWithFrame:CGRectMake(20, 0, UIScreenWidth - 40, 40)];
    textFiled.backgroundColor = [UIColor.whiteColor colorWithAlphaComponent:0.4];
    textFiled.leftViewMode = UITextFieldViewModeAlways;
    textFiled.placeholder = placeHolder;
    textFiled.textColor = UIColor.whiteColor;
    textFiled.layer.cornerRadius = 4;
    textFiled.clipsToBounds = YES;
    textFiled.attributedPlaceholder = [placeHolder st_convertAttributeStringWithKeyWord:placeHolder attributes:@{NSForegroundColorAttributeName:UIColor.whiteColor}];
    textFiled.leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, 40)];
    return textFiled;
}
- (STLabel*)lableWithText:(NSString*)text height:(CGFloat)height{
    STLabel * titleLable = [[STLabel alloc] initWithFrame:CGRectMake(0, 0, 20, height)
                                                     text:text
                                                textColor:UIColor.whiteColor
                                                     font:13
                                              isSizetoFit:NO
                                            textAlignment:NSTextAlignmentCenter];
    return titleLable;
}
@end
